﻿
// 1st arg - name of the controller
// 2nd arg - Array:
//  - biz logic - anoymous function
//  - dependicies
myApp.controller('ArticleController', ['$scope', 'MoviesService', '$routeParams', function ($scope, MoviesService, $routeParams) {
    // greeting
    $scope.greeting = "marahaba from Articles Controller!";

    // current index Id of article
    $scope.currentId = $routeParams.articleId;

    // fetch the details from the service, based on Id in routeParams....
    $scope.article = MoviesService.posts[$scope.currentId];

    $scope.startEdit = function (id) {
        console.log("User is trying to edit: ", MoviesService.posts[id]);
        // - populate modal with data
        // - show the modal
        // - wait for user to 'SaveChanges';


    }


}]);